package com.zb.stu.result;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

/**
 * Created by user on 2018/11/29.
 */
@Component
public class Text {
    @Async
    public Future<String> task1() {
        try {
            new Thread().sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("任务一");
        return new AsyncResult<>("ok");
    }

    @Async
    public Future<String> task2() {
        try {
            new Thread().sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("任务二");
        return new AsyncResult<>("ok");
    }

    @Async
    public Future<String> task3() {
        try {
            new Thread().sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("任务三");
        return new AsyncResult<>("ok");
    }
}
